<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
mb_internal_encoding("UTF-8");
date_default_timezone_set("Asia/Chongqing");
chdir("/data/www/w.mdeve.com/htdocs/");

require 'runtime.php';

$db = init_db();
$row = $db->get_rows("select id,cityid,url from weather_aqi");
for($i=1;$i<=sizeof($row)/10; $i++){
	runThread($i);
}

function runThread($i){
	$fp = fsockopen('w.mdeve.com', 80, $errno, $errmsg);
	//fputs($fp, "GET /aqi_update_proc.php?d={$i}\r\n\r\n");        //这里的第二个参数是HTTP协议中规定的请求头
	$header = "GET /shell/aqi_update_proc.php?d={$i} HTTP/1.1\r\n";
	$header .= "Host: w.mdeve.com\r\n";
	$header .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; zh-CN; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1\r\n";
	$header .= "Connection: Close\r\n\r\n";
	fwrite($fp, $header);
	//不明白的请看RFC中的定义
	fclose($fp);
}

?>